<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>穿梭框组件</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">

</head>
<body>
<div id="test1"></div>
<script src="../layui/lay/modeles/transfer.js" charset="utf-8"></script>
<script src="../layui/layui.js" charset="utf-8"></script>
<script src="../js/jquery.min.js" charset="utf-8"></script>
<script>
    layui.use('transfer', function(){
        var transfer = layui.transfer;
        var solverData = []

        $.ajax({
            type : "get",
            url : "/solver/solver_list",
            async : false,
            dataType : 'json',
            success : function(res) {
                // console.log(res)
                for (var i = 0; i < res.length; i ++) {
                    solverData.push({
                        "value": res[i].id,
                        "title": res[i].userName,
                        "disabled": "",
                        "checked": ""
                    })
                }
                console.log(solverData)
            },
            error : function() {
                layer.msg('出错了');
            }
        });

        //渲染
        transfer.render({
            elem: '#test1',
            data: solverData,
            id: 'demo1' //定义索引
        });

        // 可以重载所有基础参数
        transfer.reload('demo1', {
            title: ['待选消缺员', '已选消缺员']
        });
    });
</script>
</body>
</html>